/*
 * Copyright (c) 2005, 2014 vacoor
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package org.vacoor.nothing.web.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * @author vacoor
 */
@Entity
@Table(name = "T_CONFIG")
public class Variable implements Ordered<Variable>, Comparable<Variable> {
    @Id
    @Column(name = "VAR_NAME")
    private String name;
    @Column(name = "VAR_DESC")
    private String desc;
    @Column(name = "VAR_GROUP")
    private String group;
    @Column(name = "VAR_TYPE")
    private String type;    // bool -- radio, mstring -- textarea
    @Column(name = "VAR_VALUE")
    private String value;
    @Column(name = "VAR_ORDER")
    protected Integer order;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Override
    public Integer getOrder() {
        return order;
    }

    public void setOrder(Integer order) {
        this.order = order;
    }

    @Override
    public int compareTo(Variable other) {
        if (null == other || null == other.order) {
            return 1;
        }

        return this.order.compareTo(other.order);
    }

    @Override
    public String toString() {
        return name + " = " + value;
    }
}
